From: Keir Fraser Date: Thu, 24 Apr 2008 09:14:43 +0000 (+0100) Subject: ioemu: Save PCI device INTx line states. X-Git-Tag: archive/raspbian/4.8.0-1+rpi1~1^2~14215^2~124 X-Git-Url: https://dgit.raspbian.org/%22http:/www.example.com/cgi/%22https:/%22bookmarks://%22Dat/%22http:/www.example.com/cgi/%22https:/%22bookmarks:/%22Dat?a=commitdiff_plain;h=88bc5163bc31a31916c18dc50af09c17b9fe7996;p=xen.git ioemu: Save PCI device INTx line states. Otherwise, ioemu can be out of sync with the hypervisor after restoring guest state, if INTx lines were asserted when the state was saved. This prevents ioemu from setting the line to zero in Xen (because it thinks the line is already zero). This can allow th eguest to enter an endless IRQ loop and hang. Signed-off-by: Kazuhiro Suzuki Signed-off-by: Keir Fraser --- diff --git a/tools/ioemu/hw/pci.c b/tools/ioemu/hw/pci.c index 05329fe0ef..250dfcb3c9 100644 --- a/tools/ioemu/hw/pci.c +++ b/tools/ioemu/hw/pci.c @@ -79,18 +79,30 @@ int pci_bus_num(PCIBus *s) void pci_device_save(PCIDevice *s, QEMUFile *f) { - qemu_put_be32(f, 1); /* PCI device version */ + uint8_t irq_state = 0; + int i; + qemu_put_be32(f, 2); /* PCI device version */ qemu_put_buffer(f, s->config, 256); + for (i = 0; i < 4; i++) + irq_state |= !!s->irq_state[i] << i; + qemu_put_buffer(f, &irq_state, 1); } int pci_device_load(PCIDevice *s, QEMUFile *f) { uint32_t version_id; version_id = qemu_get_be32(f); - if (version_id != 1) + if (version_id != 1 && version_id != 2) return -EINVAL; qemu_get_buffer(f, s->config, 256); pci_update_mappings(s); + if (version_id == 2) { + uint8_t irq_state; + int i; + qemu_get_buffer(f, &irq_state, 1); + for (i = 0; i < 4; i++) + pci_set_irq(s, i, !!(irq_state >> i)); + } return 0; }